//
//  CommonGuidDetailController.m
//  homeland
//
//  Created by Alawn on 13-10-24.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "CommonGuidDetailController.h"
#import "StreetGuidDetailInfoCell.h"

#define DETAIL_TEXTVIEW_WIDTH 190.0

@interface CommonGuidDetailController ()
@end

@implementation CommonGuidDetailController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"指南详情";
    if (self.item==nil) {
         self.item = [_config objectForKey:@"dataItem"];
    }
   
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table Method
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 16;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    StreetGuidDetailInfoCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"StreetGuidDetailInfoCell" owner:self options:nil] objectAtIndex:0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.titleLabel.contentInset = UIEdgeInsetsMake(-8, -8, -8, -8);
    cell.detailTextView.contentInset = UIEdgeInsetsMake(-8, -8, -8, -8);
    if (indexPath.row == 0) {
        cell.titleLabel.text = @"事项名称";
        cell.detailTextView.text = _item.title;
    } else if (indexPath.row == 1){
        cell.titleLabel.text = @"事项编码";
        cell.detailTextView.text = _item.sxbm;
    } else if (indexPath.row == 2){
        cell.titleLabel.text = @"事项类型";
        cell.detailTextView.text = _item.category;
    } else if (indexPath.row == 3){
        cell.titleLabel.text = @"主题分类";
        cell.detailTextView.text = _item.ztsxfl;
    } else if (indexPath.row == 4){
        cell.titleLabel.text = @"事件分类";
        cell.detailTextView.text = _item.sjfl;
    } else if (indexPath.row == 5){
        cell.titleLabel.text = @"主管部门";
        cell.detailTextView.text = _item.zgbm;
    } else if (indexPath.row == 6){
        cell.titleLabel.text = @"所属部门";
        cell.detailTextView.text = _item.chnldesc;
    } else if (indexPath.row == 7){
        cell.titleLabel.text = @"受理机构";
        cell.detailTextView.text = _item.sljg;
    } else if (indexPath.row == 8){
        cell.titleLabel.text = @"办理对象";
        cell.detailTextView.text = _item.bldx;
    } else if (indexPath.row == 9){
        cell.titleLabel.text = @"办理条件";
        cell.detailTextView.text = _item.bldj;
    } else if (indexPath.row == 10){
        cell.titleLabel.text = @"办理依据";
        cell.detailTextView.text = _item.blyj;
    } else if (indexPath.row == 11){
        cell.titleLabel.text = @"所需材料";
        cell.detailTextView.text = _item.sxcl;
    } else if (indexPath.row == 12){
//        cell.titleLabel.numberOfLines = 0;
//        cell.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
        cell.titleLabel.frame = CGRectMake(10, 13, 100, 36);
        cell.titleLabel.text = @"窗口办理流程内容";
        cell.detailTextView.text = _item.ckbllc;
    } else if (indexPath.row == 13){
        cell.titleLabel.frame = CGRectMake(10, 13, 100, 36);
        cell.titleLabel.text = @"法定办理期限";
        cell.detailTextView.text = _item.fdqx;
    } else if (indexPath.row == 14){
        cell.titleLabel.frame = CGRectMake(10, 13, 100, 36);
        cell.titleLabel.text = @"承诺办理期限";
        cell.detailTextView.text = _item.cnqx;
    } else if (indexPath.row == 15){
        cell.titleLabel.text = @"收费依据";
        cell.detailTextView.text = _item.sfbzyj;
    }
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        CGFloat height = [self caculateHeightWithoutPaddingForString:_item.title AndFontSize:17.0 AndWitdh:DETAIL_TEXTVIEW_WIDTH];
        
        return MAX(44.0, height+26.0);
    }
    if (indexPath.row == 8) {
        CGFloat height = [self caculateHeightWithoutPaddingForString:_item.bldx AndFontSize:17.0 AndWitdh:DETAIL_TEXTVIEW_WIDTH];
        
        return MAX(44.0, height+26.0);
    }
    if (indexPath.row == 9) {
        CGFloat height = [self caculateHeightWithoutPaddingForString:_item.bldj AndFontSize:17.0 AndWitdh:DETAIL_TEXTVIEW_WIDTH];
        
        return MAX(44.0, height+26.0);
    }
    if (indexPath.row == 10) {
        CGFloat height = [self caculateHeightWithoutPaddingForString:_item.blyj AndFontSize:17.0 AndWitdh:DETAIL_TEXTVIEW_WIDTH];
        
        return MAX(44.0, height+26.0);
    }
    if (indexPath.row == 11) {
        CGFloat height = [self caculateHeightWithoutPaddingForString:_item.sxcl AndFontSize:17.0 AndWitdh:DETAIL_TEXTVIEW_WIDTH];
        
        return MAX(44.0, height+26.0);
    }
    if (indexPath.row == 12) {
        CGFloat height = [self caculateHeightWithoutPaddingForString:_item.ckbllc AndFontSize:17.0 AndWitdh:DETAIL_TEXTVIEW_WIDTH];
        
        return MAX(44.0+18.0, height+26.0);
    }
    if (indexPath.row == 13) {
        return 44.0+18.0;
    }
    if (indexPath.row == 14) {
        return 44.0+18.0;
    }
    return 44.0;
}
@end
